<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<p:panel header="#{msgs['massai.productionLaunch.header.consult']}">

				<h:panelGrid style="width: 100%;">
					<p:commandButton value="#{msgs['common.register']}" action="productionLaunchRegister" 
						ajax="false" immediate="true" styleClass="buttonNew" tabindex="1"
						rendered="#{sessionBean.showAction('productionProductionLaunch', 'insert')}" />
				</h:panelGrid>

				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>
					
					<h:panelGrid>
						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.accrualBasis']}" for="accrualBasis" />
							<p:inputMask mask="99/9999" id="accrualBasis" converter="accrualBasisConverter" style="width: 90px; text-align: right;"
								value="#{productionLaunchBean.spreadsheet.accrualBasis}" tabindex="2" />
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid columns="2">
						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.typePayroll']}" for="typePayroll" />
							<p:selectOneMenu id="typePayroll" value="#{productionLaunchBean.spreadsheet.typePayroll}" style="width: 160px;" 
								label="#{msgs['massai.productionLaunch.typePayroll']}" tabindex="3">
								<f:selectItems value="#{productionLaunchBean.typesPayroll}" />
							</p:selectOneMenu>
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.flow']}" for="flow" />
							<p:selectOneMenu id="flow" value="#{productionLaunchBean.spreadsheet.flow}" style="width: 160px;" 
								label="#{msgs['massai.productionLaunch.flow']}" tabindex="4">
								<f:selectItems value="#{productionLaunchBean.flows}" />
								<p:ajax event="change" global="false" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>
					
					<h:panelGrid>
						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.department']}" for="department" />
							<p:selectOneMenu id="department" value="#{productionLaunchBean.spreadsheet.department}" style="width: 330px;" 
								label="#{msgs['massai.productionLaunch.department']}" tabindex="5" converter="entityConverter">
								<f:selectItems value="#{productionLaunchBean.departmentsByUser}" />
								<p:ajax event="change" global="false" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid>
						<p:commandButton tabindex="6" value="#{msgs['common.search']}" 
							ajax="true" actionListener="#{productionLaunchBean.find()}" update="form"
							rendered="#{sessionBean.showAction('productionProductionLaunch', 'search')}" />
					</h:panelGrid>
				</fieldset>

				<p:spacer height="20px" />

				<p:dataTable var="spread" value="#{productionLaunchBean.dataModel}" rows="10" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
					currentPageReportTemplate="{currentPage} de {totalPages}" rowsPerPageTemplate="5,10,20"
					id="dataTable" lazy="true" rowIndexVar="rowIndex" emptyMessage="#{msgs['common.no.record.found']}">
					<f:facet name="header"><p:outputLabel value="#{msgs['massai.productionLaunch.list']}" /></f:facet>

					<p:column headerText="#{msgs['massai.productionLaunch.code']}" sortBy="#{spread.code}" width="80">
                        <h:outputText value="#{productionLaunchBean.completedZerosLeft(spread.code, 6)}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.productionLaunch.department']}" sortBy="#{spread.department.codeEmp}">
                        <h:outputText value="#{spread.department.codeEmp} - #{spread.department.codeDepartment} - #{spread.department.alternativeName}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.productionLaunch.accrualBasis']}" width="100" sortBy="#{spread.accrualBasis}">
                        <h:outputText value="#{spread.accrualBasis}" converter="accrualBasisConverter" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.productionLaunch.typePayroll']}" width="110" sortBy="#{spread.typePayroll}">
                        <h:outputText value="#{spread.typePayroll.typePayroll}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.productionLaunch.flow']}" sortBy="#{spread.flow}" width="100">
                        <h:outputText value="#{spread.flow.description}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.productionLaunch.finally']}" width="50" style="text-align: center;"
                    	rendered="#{sessionBean.showAction('productionProductionLaunch', 'insert')}">
						<h:commandLink
							onclick="if (! window.confirm('Após finalizada, a Planilha só poderá ser alterada com trâmite em Revisão.') ) {return false}" 
			            	actionListener="#{productionLaunchBean.finalizeSpreadsheet(spread)}">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_down01.png" 
								width="16" height="16" border="0" name="#{msgs['massai.productionLaunch.finally']}" 
								alt="#{msgs['massai.productionLaunch.finally']}" title="#{msgs['massai.productionLaunch.finally']}" />
						</h:commandLink>
					</p:column>

					<p:column headerText="#{msgs['common.printout']}" width="50" style="text-align: center;" 
                    	rendered="#{sessionBean.showAction('productionProductionLaunch', 'printout')}">
						<h:commandLink id="printout"
							onclick="if (!window.confirm('Deseja imprimir os totais dessa Planilha?') ) {return false}" 
			            	actionListener="#{productionLaunchBean.printoutTotals(spread)}" target="_blank">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_printout.png" 
								width="16" height="16" border="0" name="#{msgs['common.printout']}" 
								alt="#{msgs['common.printout']}" id="icoPrintout"
								title="#{msgs['common.printout']}" />
						</h:commandLink>
					</p:column>

					<p:column headerText="#{msgs['common.delete']}" width="60" style="text-align: center;" 
                    	rendered="#{sessionBean.showAction('productionProductionLaunch', 'delete')}">
						<h:commandLink id="delete"
							onclick="if (!window.confirm('Deseja excluir esse registro?') ) {return false}" 
			            	actionListener="#{productionLaunchBean.delete(spread)}">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_remove.png" 
								width="16" height="16" border="0" name="#{msgs['common.delete']}" 
								alt="#{msgs['common.delete']}" id="icoRemove"
								title="#{msgs['common.delete']}" />
						</h:commandLink>
					</p:column>

					<p:column headerText="#{msgs['common.update']}" width="32" style="text-align: center;"
						rendered="#{sessionBean.showAction('productionProductionLaunch', 'update')}">
						<h:link outcome="productionLaunchRegister">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_edit.png" 
								width="16" height="16" border="0" name="#{msgs['common.update']}" 
								title="#{msgs['common.update']}" alt="#{msgs['common.update']}" id="icoEdit" />
							<f:param name="param" value="#{spread.id}" />
						</h:link>
					</p:column>
                </p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>